<!--新增退还页面-->

<template>
  <div>
    <el-form :inline="true" :model="keyword" ref="searchForm" class="demo-form-inline">
      <div>
        <el-form-item label="分类">
          <el-select v-model="keyword.kind" placeholder="请选择">
            <el-option label="网络安全" value="网络安全"></el-option>
            <el-option label="计算机网络" value="计算机网络"></el-option>
            <el-option label="软件工程" value="软件工程"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="名称">
          <el-input v-model="keyword.name" placeholder="请输入名称"></el-input>
        </el-form-item>
        <el-form-item label="品牌">
          <el-select v-model="keyword.brand" placeholder="请选择">
            <el-option label="深信服" value="深信服"></el-option>
            <el-option label="华为云" value="华为云"></el-option>
            <el-option label="阿里云" value="阿里云"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="规格型号">
          <el-input v-model="keyword.spec" placeholder="请输入规格"></el-input>
        </el-form-item>
      </div>
        <el-form-item style="float: right">
          <el-button type="primary" @click="search">查询</el-button>
          <el-button type="primary" @click="resetSearchForm('searchForm')">重置</el-button>
        </el-form-item>
    </el-form>

    <el-table :data="tlList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column prop="id" label="序号" align="center"/>
      <el-table-column prop="kind" label="分类" align="center"/>
      <el-table-column prop="name" label="名称" align="center"/>
      <el-table-column prop="brand" label="品牌" align="center"/>
      <el-table-column prop="spe" label="规格型号" align="center"/>
      <el-table-column prop="unit" label="单位" align="center"/>
      <el-table-column prop="jqr" label="净领用数量" align="center"/>
      <el-table-column prop="qrOut" label="退还数量" align="center"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[5, 10, 20]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>
<script>
import { getList, delById } from "@/api/th";
import {title} from "@/settings";
export default {
  data() {
    return {
      loading: true,
      tlList: [],
      pageNum: 1,
      pageSize: 5,
      currentPage: 1,
      total: 0,
      keyword: {
        id: null,
        name: null,
        unit: null,
        kind: null,
      },
      ids:[],
      title: '',
      dialogFormVisible: false,
      wmsTl: {
        id: null,
        kind: null,
        name: null,
        brand: null,
        spe: null,
        unit: null,
        jqr: null,
        qrOut: null
      },
      wmsTlRules: {
        id: [
          { required: true, message: '编号不能为空', trigger: 'blur' }
        ],
        name: [
          { required: true, message: '项目名称不能为空', trigger: 'blur' }
        ],
      }
    }
  },
  methods: {
    title() {
      return title
    },
    fetchData() {
      let params = {
        pageNum:this.pageNum,
        pageSize:this.pageSize,
        id:this.keyword.id,
        kind:this.keyword.kind,
        name:this.keyword.name,
        brand:this.keyword.brand,
        spe:this.keyword.spe,
        unit:this.keyword.unit,
        jqr:this.keyword.jqr,
        qrOut:this.keyword.qrOut
      }
      getList(params).then(res => {
        this.tlList = res.data.list
        this.total = res.data.total
        this.pageSize = res.data.pageSize
      })
    },
    // 多选框中的数据
    handleSelectionChange(selectionRowArr) {
      this.ids = [];
      for (let i = 0; i < selectionRowArr.length; i++) {
        this.ids.push(selectionRowArr[i].id)
      }
    },
    // 页面大小改变时触发
    handleSizeChange(val) {
      this.pageSize = val;
      this.fetchData();
    },
    // 当前页面改变时触发
    handleCurrentChange(val) {
      this.pageNum = val;
      this.fetchData();
    },
    // 模糊搜索
    search() {
      this.fetchData()
    },
    // 重置
    resetSearchForm(formName) {
      this.$refs[formName].resetFields();
      this.keyword={}
      this.fetchData()
    },
    // 删除
    handleDelete(row) {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let params = {
          id:row.id
        }
        delById(params).then(res => {
          this.$message({
            message: '删除成功',
            type: 'success'
          })
          this.fetchData()
        })
      })
    }
  },
  // 生命周期函数
  created() {
    this.fetchData()
  }
}
</script>


<style scoped>

</style>
